package dujiu.luogu.branch;

import java.util.Arrays;
import java.util.Scanner;

public class P1909 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int total = 0;
        int[] arr = new int[3];
        for (int i = 0; i < 3; i++) {
            int num = sc.nextInt();
            int price = sc.nextInt();
            if (n % num == 0){
                total = (n / num) * price;
            }else {
                total = ((n / num) + 1) * price;
            }
            arr[i] = total;
        }
        Arrays.sort(arr);
        System.out.println(arr[0]);
        sc.close();
    }
}
